import request from './request'
import {passwordHash} from '../utilities/crypto'

export function query ({currentPage = 1, perPage = 10, mchtName} = {}) {
  return request({
    url: '/console/mcht/queryMchtAllInfo.do',
    method: 'POST',
    body: {currentPage, perPage, mchtName}
  })
}

export function queryDetail (mchtId) {
  return request({
    url: '/console/mcht/queryMchtDtail.do',
    method: 'POST',
    body: {mchtId}
  })
}

export function create ({mchtName, userName, mchtDetails, userPwd}) {
	userPwd = passwordHash(userPwd)
  return request({
    url: '/console/mcht/addMchtInfo.do',
    method: 'POST',
    body: {mchtName, userName, mchtDetails, userPwd}
  })
}

export function edit ({mchtId, mchtName, userName,userId, mchtDetails}) {
  return request({
    url: '/console/mcht/updateMchtInfo.do',
    method: 'POST',
    body: {mchtId, mchtName, userName, userId, mchtDetails}
  })
}

export function forbidden (mchtId) {
  return request({
    url: '/console/mcht/usingNotMchtInfo.do',
    method: 'POST',
    body: {mchtId}
  })
}

export function use (mchtId) {
  return request({
    url: '/console/mcht/usingMchtInfo.do',
    method: 'POST',
    body: {mchtId}
  })
}